# 经纬度转10进制
def dms_to_dd(longitude: str, latitude: str) -> tuple:
    """

    :param longitude:
    :param latitude:
    :return:
    """

    def convert_dms_to_dd(dms_str):
        dms = dms_str.split()
        degrees = float(dms[0])
        minutes = float(dms[1])
        seconds = float(dms[2])
        direction = dms[3]

        dd = degrees + minutes / 60 + seconds / 3600

        if direction in ['S', 'W']:
            dd *= -1

        return dd

    longitude_dd = convert_dms_to_dd(longitude)
    latitude_dd = convert_dms_to_dd(latitude)

    return longitude_dd, latitude_dd


if __name__ == '__main__':
    # print(f"22: {dms_to_dd('108 12 4.542 E', '22 36 13.993 N')}")
    # print(f"04: {dms_to_dd('108 10 27.819 E', '22 34 49.916 N')}")
    print(f"04: {dms_to_dd('108 10 27.881 E', '22 34 49.6 N')}")
    print(f"22: {dms_to_dd('108 12 5.04 E', '22 36 14.15 N')}")
    print(f"23: {dms_to_dd('108 11 12.509 E','22 37 5.773 N')}")
    print(f"23: {dms_to_dd('108 9 51.447 E','22 35 55.018 N')}")
    print(dms_to_dd('106 38 290 E', '29 43 080 N'))
    print(dms_to_dd('106 39 593 E', '29 43 439 N'))

